package com.example.blog.util.HomeWorkUtils;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.blog.mapper.HomeWorkMapper;
import com.example.blog.pojo.HomeWork;
import com.xiaoleilu.hutool.json.JSONUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
@Component
public class CorrectUtils {
    @Resource
    private HomeWorkMapper HomeWorkMapper;
    //获取提交作业用户昵称
    public String getSubject(Integer SendHomeworkId) {
        QueryWrapper<HomeWork> Wrapper = new QueryWrapper<>();
        QueryWrapper<HomeWork> eq = Wrapper.eq("id", SendHomeworkId);
        List<HomeWork> list = HomeWorkMapper.selectList(eq);
        String json = JSONUtil.toJsonStr(list);
        HomeWork HomeWork = JSONObject.parseObject(json, HomeWork.class);
        return HomeWork.getSubject();
    }
}
